#include<bits/stdc++.h>
using namespace std;
vector<int> gf;
int a,s,m,n,i,b,f[100001]={-1};
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
freopen("duel1.in","r",stdin);
freopen("duel1.out","w",stdout);
cin>>n;
m=n;
b=n;
while(n--){
  cin>>a;
  gf.push_back(a);
}
sort(gf.begin(),gf.end());
do{
for(i=0;i<=b-1;i++){
   f[i]=-1;
   }
i=0;
s=0;
while(i<b-1){
    if(f[i]==-3)i++;
    if(i!=b-1){
    if(gf[i]>gf[i+1]){
       f[i]=-2;
       f[i+1]=-3;
    }else{
      f[i]=-2;
    }}
    i++;
}
if((f[b-1]==-1)&&(gf[b-1]<=gf[0])){
    f[b-1]=-2;
}else{
if((f[b-1]==-1)&&(gf[b-1]>gf[0])){
    f[b-1]=-2;
    f[0]=-3;
}
}
for(int j=0;j<=b-1;j++){
    if(f[j]==-2)s++;
}
if(s<=m) m=s;
}while(next_permutation(gf.begin(),gf.end()));
cout<<m;
return 0;
}
